<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app\lib\WeixinUtils;

/* @var $this yii\web\View */
/* @var $content string 字符串 */

//echo "card order-submit";
//exit;
$web = Url::to("@web");
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>订单确认</title>
    <link type="text/css" href="<?=$web?>/css/base.css" rel="stylesheet" />
    <link type="text/css" href="<?=$web?>/css/wx/order-submit.css" rel="stylesheet" />
    <script src="<?=$web?>/js/jquery.js"></script>
    <script src="<?=$web?>/js/tools.js"></script>
    <?php
     $TOTALPRICE=$orderInfo['PRICE'];
     require_once Yii::$app->viewPath.'/wx-calc-price.php';
    ?>
    <script>

        $(function ($) {
            var w = $(document).width();
            if (w > 640) {
                w = 640;
            }
            $("body").css("font-size", w * 20 / 320);

            /*$("#btnOpenList").click(function () {
                $('.goodlist').toggle();
                $('.btn_span').toggle();
            });*/

          
        });

        //扣除朵拉币
        function cashCoin(order_code,current_coin,realPrice){
            var data = {};
            data.order_code = order_code;
            data.current_coin = current_coin;
            data.realPrice = realPrice;
            var re = returnjson("<?=Url::to(["wx-home/cash-dora-coin-handle"])?>", data);
            if (re.flag == 1) {
                return true;
            }else{
                alert(re.msg);
                return false;
            }
        }
        //购买
        function callPay(){


            //支付
            var data = {};
            data.code = "<?=$orderInfo['ID']?>";
            data.blessing = $("#v_blessing").val();
            data.current_coin = $('#txt_duola_coin').val();
            var re = returnjson("<?=Url::to(["wx-biz/pay-handle"])?>", data);
            if (re.flag == 1) {
                if (re.price > 0) {
                    WeixinJSBridge.invoke(
                        'getBrandWCPayRequest',
                        re.jsApiParameters,
                        function (res) {
//                        alert(res.err_msg);
                            if (res.err_msg == "get_brand_wcpay_request:ok") {
                                cashCoin(data.code, data.current_coin, 0);
                                window.location.href = "<?=Url::to(["wx-biz/pay-card-success"]);?>?id=" + re.code;

                            }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
                        }
                    );
                }else{//不用支付现金情况
                    cashCoin(data.code, data.current_coin, 0);
                    window.location.href = "<?=Url::to(["wx-biz/pay-card-success"]);?>?id=" + re.code;
                }
                //
            } else {
                if(re.testcode){
                    alert('支付金额：'+re.price+'分');
                    cashCoin(data.code,data.current_coin,re.price);
                    window.location.href = "<?=Url::to(["wx-biz/pay-card-success"]);?>?id="+ re.testcode;
                    return;
                }
                alert(re.msg);
                return false;
            }
        }

    </script>
</head>
<body>
<div class="main">
    <div class="lines" style='padding-top: 1.5em; overflow: auto;'>
        <div style="height: 2em;" id="btnOpenList">
            <div style='display:block;color:#a4a4a4;' class="btn_span font1" >+</div>
            <div style='display:none;color:#f94c4d;' class="btn_span font1" >-</div>
            <div style='margin-left: 0.5em; float: left;' class="font1">
                    <div style='float: left;width: 11em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;'><?=$card['NAME']?></div>  x1
            </div>
            <div style='width: 8.4em;' class="font_m">单价：¥<?=$orderInfo['PRICE']?></div>
        </div>
        <!--goods-list-->
        <div class="goodlist" style="display:none;">


<!--
            <div >
                <div class="sp"></div>
                <div class="content">
                    <div class="img">
                        <img src="<?/*=$web*/?>/img/bag/order-submit/goods.jpg"  />
                    </div>

                    <div  class="font1 txt">
                        <div>
                            夏季新品情侣居家凉拖鞋男女室内防滑软底
                            拖鞋浴室塑料漏水凉拖鞋
                        </div>
                        <div style="margin-top: 1em;" class="font2">
                            ￥19.9
                        </div>
                    </div>

                </div>
            </div>
-->
        </div>
    </div>

    <div class="lines" style=''>
        <div style='height: 1.1em; padding-top: 0.65em;'>
            <div style='margin-left: 0.5em; float: left;' class="font1">运费</div>
            <div style='width:5em;' class="font_m">¥0</div>
        </div>
        <div class="sp"></div>
        <div style='height: 1.1em; padding-top: 0.65em;'>
            <div style='margin-left: 0.5em; float: left;' class="font1">总价</div>
            <div style='width:5em;' class="font_m">¥<?=$orderInfo['PRICE']?></div>
        </div>
    </div>

    <div class="lines" style=''>
        <div style='height: 1.4em; padding-top: 0.55em;'>
            <div style='margin-left: 0.5em; float: left;' class="font1">朵拉币   您共有 <span class="font2"><?=$user_info['DORACOIN_ACCOUNT']?></span> 朵拉币，可当现金使用</div>
        </div>
        <div class="sp"></div>
        <div style='height: 1.85em; line-height:1.85em;'>
            <div style='margin-left: 0.5em; float: left;border-right: 1px #efefef solid; padding-right:0.6em;' ><span class="font1">使用</span></div>
            <div style='margin-left: 0.5em; float: left;border-right: 1px #efefef solid; padding-right:0.6em;' >
                <input id="txt_duola_coin"  type="tel" class="font3" style="width:3.7em;height:100%;border:0px;" value="0"
                       oninput="checkNumVal_int(this);calc_coin(this.value);">
            </div>
            <div style='margin-left: 0.5em; float: left;' ><span class="font1">朵拉币</span></div>

            <div style='width: 8em;' class="font_m font2" id="txt_duola_coinToMoney">抵：<div id="exchange_money_dom" style="float: right;">¥0</div></div>
        </div>
        <div class="sp"></div>
        <div style='padding-top: 1em; height: 1.95em;'>
            <div style='margin-left: 0.5em; float: left;' class="font1">实际支付 </div>
            <div style='width: 5em; color: #de313d;' class="font_m"><div  style="float: right;" id="realPrice_dom">¥28600.59</div></div>
        </div>
    </div>

    <div class="lines" style=''>

        <div style='width: 100%; height: 2.1em;'>
            <img src="<?=$web?>/img/wx/order-submit/sp3.jpg" style="height: 100%;width:100%;" /></div>
        <div style="width: 100%; height: 6em;">
                <textarea id="v_blessing" style="width: 100%; height: 100%; font-size: 1em; border-top: 0px;" placeholder="输入您想发送的祝福语"></textarea>
        </div>
    </div>
    <div onclick="callPay();" style='width: 100%; background-color: #d6000f; height: 1.55em; text-align: center; color: #ffffff; margin-top: 1.2em; padding-top: 0.95em; margin-bottom: 1.2em;'>
        微信支付
    </div>
</div>

</body>
</html>

